package Model;

public class WineCabinet {

	public String get6DData(String rawData) {

		String result = "";
		rawData = rawData.replaceAll(" +", " ");
		String arrayData[] = rawData.split(" ");

		int intCount;
		Integer countNum = 1;
		String washOrderCommand = "";

		// 冷藏显示
		String RefDisplay = arrayData[12];
		intCount = Integer.parseInt(RefDisplay, 16);
		washOrderCommand = Integer.toString((intCount - 38));
		result += (countNum++) + ":" + washOrderCommand + "@";

		// 冷冻显示
		String FrzDisplay = arrayData[13];
		intCount = Integer.parseInt(FrzDisplay, 16);
		washOrderCommand = Integer.toString((intCount - 38));
		result += (countNum++) + ":" + washOrderCommand + "@";

		// 母婴室显示
		String VarDisplay = arrayData[14];
		intCount = Integer.parseInt(VarDisplay, 16);
		washOrderCommand = Integer.toString(intCount);
		result += (countNum++) + ":" + washOrderCommand + "@";

		// 冷藏设定
		String SetRef = arrayData[15];
		intCount = Integer.parseInt(SetRef, 16);
		washOrderCommand = Integer.toString((intCount + 2));
		result += (countNum++) + ":" + washOrderCommand + "@";

		// 冷冻设定
		String SetFrz = arrayData[16];
		intCount = Integer.parseInt(SetFrz, 16);
		washOrderCommand = Integer.toString((intCount - 20));
		result += (countNum++) + ":" + washOrderCommand + "@";

		// 母婴室设定
		String SetVar = arrayData[17];
		intCount = Integer.parseInt(SetVar, 16);
		washOrderCommand = Integer.toString(intCount);
		result += (countNum++) + ":" + washOrderCommand + "@";

		// 设置保留
		String SetBac = arrayData[18];
		String SetBacbinaryString = Integer.toBinaryString(Integer.parseInt(SetBac, 16));
		while (SetBacbinaryString.length() < 8) {
			SetBacbinaryString = "0" + SetBacbinaryString;
		}

		String halfSetBacBinaryString = String.valueOf(SetBacbinaryString.charAt(4))
				+ String.valueOf(SetBacbinaryString.charAt(5)) + String.valueOf(SetBacbinaryString.charAt(6))
				+ String.valueOf(SetBacbinaryString.charAt(7));
		intCount = Integer.parseInt("0000" + halfSetBacBinaryString, 16);
		washOrderCommand = Integer.toString(intCount);
		result += (countNum++) + ":" + washOrderCommand + "@";
		// 保持显示板常亮
		char SetDisplayKeepOn = SetBacbinaryString.charAt(3);
		switch (SetDisplayKeepOn) {
		case '0':
			washOrderCommand = "否";
			break;
		case '1':
			washOrderCommand = "是";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";

		// 速冻设定
		char SetSuperCool = SetBacbinaryString.charAt(2);
		switch (SetSuperCool) {
		case '0':
			washOrderCommand = "否";
			break;
		case '1':
			washOrderCommand = "是";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";

		// 照明设定
		char SetLight = SetBacbinaryString.charAt(1);
		switch (SetLight) {
		case '0':
			washOrderCommand = "否";
			break;
		case '1':
			washOrderCommand = "是";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";

		// 杀菌设定
		char SetUv = SetBacbinaryString.charAt(0);
		switch (SetUv) {
		case '0':
			washOrderCommand = "否";
			break;
		case '1':
			washOrderCommand = "是";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";

		// 故障预留0，母婴传感器故障F5，湿度传感器故障A1，环温传感器故障H8，故障预留1，冷藏传感器故障F4，化霜传感器故障F0，冷冻传感器故障F6
		String fdrerhve = arrayData[19];
		String fdrerhvebinaryString = Integer.toBinaryString(Integer.parseInt(fdrerhve, 16));
		while (fdrerhvebinaryString.length() < 8) {
			fdrerhvebinaryString = "0" + fdrerhvebinaryString;
		}
		// 故障预留0
		char ErrorBak0 = fdrerhvebinaryString.charAt(7);
		switch (ErrorBak0) {
		case '0':
			washOrderCommand = "false";
			break;
		case '1':
			washOrderCommand = "true";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";
		// 母婴传感器故障F5
		char VarSnrorError = fdrerhvebinaryString.charAt(6);
		switch (VarSnrorError) {
		case '0':
			washOrderCommand = "否";
			break;
		case '1':
			washOrderCommand = "是";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";
		// 湿度传感器故障A1
		char HumiditySnrError = fdrerhvebinaryString.charAt(5);
		switch (HumiditySnrError) {
		case '0':
			washOrderCommand = "无";
			break;
		case '1':
			washOrderCommand = "有";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";
		// 环温传感器故障H8
		char RoomSurError = fdrerhvebinaryString.charAt(4);
		switch (RoomSurError) {
		case '0':
			washOrderCommand = "无";
			break;
		case '1':
			washOrderCommand = "有";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";

		// 故障预留1
		char ErrorBak1 = fdrerhvebinaryString.charAt(3);
		switch (ErrorBak1) {
		case '0':
			washOrderCommand = "否";
			break;
		case '1':
			washOrderCommand = "是";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";
		// 冷藏传感器故障F4
		char RefSnrError = fdrerhvebinaryString.charAt(2);
		switch (RefSnrError) {
		case '0':
			washOrderCommand = "无";
			break;
		case '1':
			washOrderCommand = "有";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";
		// 化霜传感器故障F0
		char DefSnrErrirF0 = fdrerhvebinaryString.charAt(1);
		switch (DefSnrErrirF0) {
		case '0':
			washOrderCommand = "无";
			break;
		case '1':
			washOrderCommand = "有";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";
		// 冷冻传感器故障F6
		char FrzSnrError = fdrerhvebinaryString.charAt(0);
		switch (FrzSnrError) {
		case '0':
			washOrderCommand = "无";
			break;
		case '1':
			washOrderCommand = "有";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";

		// 冷冻室温度过低，母婴室温度过低L2，冷藏室温度过低L1，化霜故障，风扇故障
		String fdrvfe = arrayData[20];
		String fdrvfebinaryString = Integer.toBinaryString(Integer.parseInt(fdrvfe, 16));
		while (fdrvfebinaryString.length() < 8) {
			fdrvfebinaryString = "0" + fdrvfebinaryString;
		}

		// 冷冻室温度过低
		char FrzLow = fdrerhvebinaryString.charAt(4);
		switch (FrzLow) {
		case '0':
			washOrderCommand = "无";
			break;
		case '1':
			washOrderCommand = "有";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";

		// 母婴室温度过低L2
		char VarLow = fdrerhvebinaryString.charAt(3);
		switch (VarLow) {
		case '0':
			washOrderCommand = "否";
			break;
		case '1':
			washOrderCommand = "是";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";
		// 冷藏室温度过低L1
		char RefLow = fdrerhvebinaryString.charAt(2);
		switch (RefLow) {
		case '0':
			washOrderCommand = "无";
			break;
		case '1':
			washOrderCommand = "有";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";
		// 化霜故障
		char DeforstFunkErr = fdrerhvebinaryString.charAt(1);
		switch (DeforstFunkErr) {
		case '0':
			washOrderCommand = "无";
			break;
		case '1':
			washOrderCommand = "有";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";
		// 风扇故障
		char FanError = fdrerhvebinaryString.charAt(0);
		switch (FanError) {
		case '0':
			washOrderCommand = "无";
			break;
		case '1':
			washOrderCommand = "有";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";

		//显示板接受故障E0，与主控板不匹配Er，开门超过1分钟，开门超过60分钟，与母婴板通讯故障，主控板接受故障E0
		String mvooemd = arrayData[21];
		String mvooemdbinaryString = Integer.toBinaryString(Integer.parseInt(mvooemd, 16));
		while (mvooemdbinaryString.length() < 8) {
			mvooemdbinaryString = "0" + mvooemdbinaryString;
		}
		
		
		// 显示板接受故障E0
		char DispRecErr = mvooemdbinaryString.charAt(6);
		switch (DispRecErr) {
		case '0':
			washOrderCommand = "否";
			break;
		case '1':
			washOrderCommand = "是";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";
		// 与主控板不匹配Er
		char ModleErrToWifi = mvooemdbinaryString.charAt(5);
		switch (ModleErrToWifi) {
		case '0':
			washOrderCommand = "无";
			break;
		case '1':
			washOrderCommand = "有";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";

		// 开门超过1分钟
		char OpenDoor1Min = mvooemdbinaryString.charAt(3);
		switch (OpenDoor1Min) {
		case '0':
			washOrderCommand = "否";
			break;
		case '1':
			washOrderCommand = "是";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";
		//开门超过60分钟
		char OpenDoor60Min = mvooemdbinaryString.charAt(2);
		switch (OpenDoor60Min) {
		case '0':
			washOrderCommand = "否";
			break;
		case '1':
			washOrderCommand = "是";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";
		// 与母婴板通讯故障
		char VarNoLink = mvooemdbinaryString.charAt(1);
		switch (VarNoLink) {
		case '0':
			washOrderCommand = "否";
			break;
		case '1':
			washOrderCommand = "是";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";
		// 主控板接受故障E0
		char MainRecErr = mvooemdbinaryString.charAt(0);
		switch (MainRecErr) {
		case '0':
			washOrderCommand = "无";
			break;
		case '1':
			washOrderCommand = "有";
			break;
		default:
			break;
		}
		result += (countNum++) + ":" + washOrderCommand + "@";

		return result;

	}
	


}
